<template>
  <div>

    <ul class="mui-table-view">
      <li class="mui-table-view-cell mui-media" v-for="item in list" :key="item.id">
        <router-link :to="'/home/newsinfo/' + item.id">
          <img class="mui-media-object mui-pull-left" src="http://ofv795nmp.bkt.clouddn.com//upload/201504/16/201504161149414479.jpg">
          <div class="mui-media-body">
            <h1>{{item.title}}</h1>
            <p class='mui-ellipsis'>
              <span>发表时间：{{item.add_time | dataFormat}}</span>
              <span>点击{{item.click}}次</span>
            </p>
          </div>
        </router-link>
      </li>
    </ul>

  </div>
</template>

<script>
export default {
  data() {
    return {
      list: []
    }
  },
  created() {
    this.getNewsList();
  },
  methods: {
    getNewsList() {
      var url = 'api/getnewslist';
      this.$http.get(url).then(res => {
        var result = res.body;
        if (result.status === 0) {
          // console.log(result.message);
          this.list = result.message;
        } else {
          console.log('新闻列表获取失败！');
        }
      });
    }
  }
}
</script>

<style lang="scss" scoped>
.mui-media-body {
  h1 {
    font-size: 14px;
  }
  p.mui-ellipsis {
    color: #26A2FF;
    font-size: 12px;
    display: flex;
    justify-content: space-between;
  }
}
</style>